/* 
 * File:   Camera.c
 * Author: kraken
 *
 * Created on 5 février 2011, 22:31
 */
#include <stdlib.h>
#include <stdio.h>
#include <SDL/SDL.h>

#if (defined(__APPLE__))
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#else
#include <GL/gl.h>
#include <GL/glu.h>
#endif
#include "Camera.h"



float vitesseDeplacement = 0.1f;
double angleZ = 0;
double angleX = 0;
float zoomPlus = 1;
float zoomMoins = 1;

void Camera_BACKSPACE() {
    /*reinitialisation de la scene*/
    zoomPlus = 1;
    zoomMoins = 1;
    angleX = 0;
    angleZ = 0;
    /*glMatrixMode(GL_PROJECTION);*/
    glLoadIdentity();
    gluPerspective(70, (double) 640 / 480, 1, 1000);
    /*glMatrixMode(GL_MODELVIEW);*/
    glLoadIdentity();
    gluLookAt(3, 0, 3,
            0, 0, 0,
            0, 0, 1);
}
/*==================*/
/*====== ZOOM =======*/

/*==================*/
void Camera_PAGEUP() {
    zoomPlus += 0.01;
    glScalef(1.0f * zoomPlus, 1.0f * zoomPlus, 1.0f * zoomPlus);
}

void Camera_PAGEDOWN() {
    zoomMoins -= 0.01;
    glScalef(1.0f * zoomMoins, 1.0f * zoomMoins, 1.0f * zoomMoins);
}




/*=========================*/
/*====== ORientataion cam =======*/

/*========================*/
void Camera_UP() {
    angleX = 50 * vitesseDeplacement;
    glRotated(angleX, 0, 1, 0);
}

void Camera_DOWN() {
    angleX = -50 * vitesseDeplacement;
    glRotated(angleX, 0, 1, 0);
}

void Camera_LEFT() {
    angleZ = 50 * vitesseDeplacement;
    glRotated(angleZ, 0, 0, 1);
}

void Camera_RIGHT() {
    angleZ = -50 * vitesseDeplacement;
    glRotated(angleZ, 0, 0, 1);
}
/*=========================*/
/*====== déplacement cam =======*/

/*========================*/
void Camera_z() {
    glTranslated(1 * vitesseDeplacement, 0, 0);
}

void Camera_s() {
    glTranslated(-1 * vitesseDeplacement, 0, 0);
}

void Camera_q() {
    glTranslated(0, 1 * vitesseDeplacement, 0);
}

void Camera_d() {
    glTranslated(0, -1 * vitesseDeplacement, 0);
}

void Camera_a() {
    glTranslated(0, 0, -1 * vitesseDeplacement);
}

void Camera_e() {
    glTranslated(0, 0, 1 * vitesseDeplacement);
}